using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LaZhu : MonoBehaviour
{

    public Light light;

    public float moveSpeed = 0.5f;

    public float flashSpeed = 10;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        // 进行移动
        light.transform.Translate(Vector3.right * moveSpeed * Time.deltaTime);
        if (light.transform.position.x >= 1)
        {
            moveSpeed = -1 * Math.Abs(moveSpeed);
        }
        else if (light.transform.position.x <= 0.8)
        {
            moveSpeed = Math.Abs(moveSpeed);
        }

        // 进行闪烁
        light.intensity += flashSpeed * Time.deltaTime;
        if (light.intensity >= 1)
        {
            flashSpeed = -1 * Math.Abs(flashSpeed);
        }
        else if (light.intensity <= 0.5f)
        {
            flashSpeed = Math.Abs(flashSpeed);
        }
    }
}
